<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Jedrzej\Pimpable\PimpableTrait;

class SystemAttachmentCategory extends Model
{
    use HasFactory;
    use PimpableTrait;

    public $searchable = [
        'pid',
        'name',
        'english_name',
    ];

    public $fillable = [
        'pid',
        'name',
        'english_name',
    ];

    public $sortable = [
        'pid',
    ];

    protected $defaultSortCriteria = ['id,desc'];

    /**
     * 附件分类下的所有附件
     */
    public function systemAttachment()
    {
        return $this->hasMany(SystemAttachment::class, 'pid','id');
    }

    /**
     * 分类的子类
     */
    public function children()
    {
        return $this->hasMany(SystemAttachment::class,'pid','id');
    }
}
